﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Infrastructure;
using BenefitHelper.Sys;
/*
    2012-2-17 David检查正常
 */
namespace BenefitHelper.DB
{
    public class DBManager : DbContext
    {
        private readonly static string CONNECTION_STRING = "name=ContentString";

        #region Server表
        public DbSet<Data.ServerData.T_CashIO_History> CashIOHistorys { get; set; }
        public DbSet<Data.ServerData.T_SettlementMoney> SettlementMoneys { get; set; }
        public DbSet<Sys.TradeHistory> TradeHistorys { get; set; }
        public DbSet<Data.ServerData.T_PositionDetail_History> PositionDetailHistory { get; set; }
        public DbSet<Data.ServerData.T_PositionSummaryDelivery> PostionSummaryDelivery { get; set; }
        public DbSet<Data.ServerData.T_TradeDetail_History> TradeDetailHistory { get; set; }
        public DbSet<Data.ServerData.T_TradeDetail_Summary> TradeDetailSummary { get; set; }
        public DbSet<Data.ServerData.T_ClosePositionDetail_History> ClosePositionDetail { get; set; }
        #endregion

        #region 系统属性
        public DbSet<Sys.Operator> Operators { get; set; }
        public DbSet<Sys.Account> Accounts { get; set; }
        public DbSet<Sys.Batch> Batches { get; set; }
        public DbSet<Config.GlobalConfig> GlobalConfig { get; set; }
        //public DbSet<Config.GlobalPrower> GlobalPrower { get; set; }
        public DbSet<Sys.Product> Product { get; set; }
        public DbSet<Sys.Instrument> Instrument { get; set; }
        public DbSet<Sys.Exchange> Exchange { get; set; }
        public DbSet<Config.UserConfig> UserConfig { get; set; }
        //public DbSet<Config.UserPrower> UserPrower { get; set; }
        public DbSet<Sys.Groups> Groups { get; set; }
        public DbSet<Sys.GroupMaster> GroupMaster { get; set; }
        public DbSet<Sys.GroupOperators> GroupOperators { get; set; }
        public DbSet<Sys.OperatorAccount> OperatorAccount { get; set; }
        public DbSet<Sys.Broker> Broker { get; set; }
        public DbSet<Sys.User> User { get; set; }
        public DbSet<Common.Module.Permissions.Model.T_GroupManager> GroupManager { get; set; }
        public DbSet<Common.Module.Permissions.Model.T_Action> Action { get; set; }
        public DbSet<Common.Module.Permissions.Model.T_ActionGroup> ActionGroup { get; set; }
        public DbSet<Common.Module.Permissions.Model.T_MasterGroup> MasterGroup { get; set; }
        public DbSet<Sys.DayGroupOperators> DayGroupOperators { get; set; }
        public DbSet<Sys.DayOperatorAccount> DayOperatorAccounts { get; set; }
        public DbSet<Sys.DayGroupMaster> DayGroupMaster { get; set; }
        public DbSet<Sys.OperatorInfo> OperatorInfo { get; set; }
        public DbSet<Sys.OperatorCouldSeeGroups> OperatorCouldSeeGroups { get; set; }
        #endregion

        #region 账户数据相关的表
        public DbSet<Data.Day.AccountDayChange> AccountDayChange { get; set; }
        public DbSet<Data.Day.AccountDayAnalysis> AccountDayAnalysis { get; set; }
        public DbSet<Data.Day.DayWinOrLoseTick> DayWinOrLoseTick { get; set; }
        public DbSet<Data.Day.AccountDayTradeInstrument> AccountDayTradeInstrument { get; set; }
        public DbSet<Data.Day.AccountDayTradeInstrumentAnalysis> AccountDayTradeInstrumentAnalysis { get; set; }
        public DbSet<Data.Day.AccountDayTradeProduct> AccountDayTradeProduct { get; set; }
        public DbSet<Data.Day.AccountDayTradeProductAnalysis> AccountDayTradeProductAnalysis { get; set; }
        public DbSet<Data.Day.AccountDayMoney> AccountDayMoney { get; set; }
        public DbSet<Data.Month.AccountMonthChange> AccountMonthChange { get; set; }
        public DbSet<Data.Month.AccountMonthAnalysis> AccountMonthAnalysis { get; set; }
        public DbSet<Data.Month.AccountMonthTradeInstrument> AccountMonthTradeInstrument { get; set; }
        public DbSet<Data.Month.AccountMonthTradeInstrumentAnalysis> AccountMonthTradeInstrumentAnalysis { get; set; }
        public DbSet<Data.Month.AccountMonthTradeProduct> AccountMonthTradeProduct { get; set; }
        public DbSet<Data.Month.AccountMonthTradeProductAnalysis> AccountMonthTradeProductAnalysis { get; set; }
        public DbSet<Data.Week.AccountAvgWeek> AccountAvgWeek { get; set; }
        public DbSet<Data.Month.AccountMonthAvg> AccountMonthAvg { get; set; }
        public DbSet<Data.Month.CompanyAvgMonth> CompanyAvgMonth { get; set; }
        public DbSet<Data.Week.CompanyAvgWeek> CompanyAvgWeek { get; set; }
        public DbSet<Data.Day.CompanyAvgDay> CompanyAvgDay { get; set; }
        public DbSet<Data.Day.AccountFiveDayAvg> AccountFiveDayAvg { get; set; }
        public DbSet<Data.Day.BatchAvgDay> BatchAvgDay { get; set; }
        public DbSet<Data.Week.BatchAvgWeek> BatchAvgWeek { get; set; }
        public DbSet<Data.Month.BatchAvgMonth> BatchAvgMonth { get; set; }
        public DbSet<Data.Day.GroupAvgDay> GroupAvgDay { get; set; }
        public DbSet<Data.Week.GroupAvgWeek> GroupAvgWeek { get; set; }
        public DbSet<Data.Month.GroupAvgMonth> GroupAvgMonth { get; set; }
        public DbSet<Data.Week.GroupWeekSum> GroupWeekSum { get; set; }
        //    public DbSet<Data.Week.GroupWeekSumAnalysis> GroupWeekSumAnalysis { get; set; }
        public DbSet<Data.Month.GroupMonthSum> GroupMonthSum { get; set; }
        //    public DbSet<Data.Month.GroupMonthSumAnalysis> GroupMonthSumAnalysis { get; set; }
        public DbSet<Data.Year.GroupYearSum> GroupYearSum { get; set; }
        //   public DbSet<Data.Year.GroupYearSumAnalysis> GroupYearSumAnalysis { get; set; }
        public DbSet<Data.Day.GroupDayChange> GroupDayChange { get; set; }
        //   public DbSet<Data.Day.GroupDayAnalysis> GroupDayAnalysis { get; set; }
        public DbSet<Data.Day.DayTradeInfo> DayTradeInfo { get; set; }
        public DbSet<Data.Month.AccountMonthMoney> AccountMonthMoney { get; set; }
        public DbSet<Data.Day.BrokerageDayTradeInfo> BrokerageDayTradeInfo { get; set; }
        public DbSet<Data.Month.BrokerageMonthTradeInfo> BrokerageMonthTradeInfo { get; set; }
        public DbSet<Data.Year.AccountYearMoney> AccountYearMoney { get; set; }
        public DbSet<Data.Month.AccountMonthExpected> AccountMonthExpected { get; set; }
        public DbSet<Data.Week.AccountWeekExpected> AccountWeekExpected { get; set; }
        public DbSet<Data.Day.YieldInHoldTime> YieldInHoldTime { get; set; }
        public DbSet<Data.Day.AccountDayPositionDelivery> AccountDayPositionDelivery { get; set; }
        #endregion

        #region 用户数据相关的表
        public DbSet<Data.Day.OperatorPublish> OperatorPublish { get; set; }
        public DbSet<Data.Week.OperatorWeekSort> OperatorWeekSort { get; set; }
        public DbSet<View.GroupDayAvg> GroupDayAvg { get; set; }
        public DbSet<View.OperatorAvgWeek> OperatorAvgWeek { get; set; }
        public DbSet<View.OperatorDayChange> OperatorDayChange { get; set; }
        public DbSet<View.OperatorDayDirectionInfoData> OperatorDayDirectionInfoData { get; set; }
        public DbSet<View.OperatorDayMoney> OperatorDayMoney { get; set; }
        public DbSet<View.OperatorDayPosition> OperatorDayPosition { get; set; }
        public DbSet<View.OperatorDayProductInfo> OperatorDayProductInfo { get; set; }
        public DbSet<View.OperatorDayTick> OperatorDayTick { get; set; }
        public DbSet<View.OperatorDayTradeInfoData> OperatorDayTradeInfoData { get; set; }
        public DbSet<View.OperatorDayWinNumData> OperatorDayWinNumData { get; set; }
        public DbSet<View.OperatorFiveDayAvg> OperatorFiveDayAvg { get; set; }
        public DbSet<View.OperatorMonthAvg> OperatorMonthAvg { get; set; }
        public DbSet<View.OperatorMonthExpected> OperatorMonthExpected { get; set; }
        public DbSet<View.OperatorMonthSum> OperatorMonthSun { get; set; }
        public DbSet<View.OperatorWeekExpected> OperatorWeekExpected { get; set; }
        public DbSet<View.OperatorWeekSum> OperatorWeekSum { get; set; }
        public DbSet<View.OperatorYearSum> OperatorYearSum { get; set; }
        public DbSet<View.OperatorYearAvg> OperatorYearAvg { get; set; }
        public DbSet<View.OperatorYearExpected> OperatorYearExpected { get; set; }
        public DbSet<View.OperatorYieldInHoldTime> OperatorYieldInHoldTime { get; set; }
        public DbSet<View.OperatorMonthProductInfo> OperatorMonthProductInfo { get; set; }
        public DbSet<View.OperatorYearProductInfo> OperatorYearProductInfo { get; set; }
        public DbSet<Data.Year.BatchAvgYear> BatchAvgYear { get; set; }
        public DbSet<Data.Year.GroupAvgYear> GroupAvgYear { get; set; }
        public DbSet<Data.Year.CompanyYearAvg> CompanyYearAvg { get; set; }
        public DbSet<View.OperatorMonthTick> OperatorMonthTick { get; set; }
        public DbSet<View.OperatorYearTick> OperatorYearTick { get; set; }
        public DbSet<View.OperatorMonthMoney> OperatorMonthMoney { get; set; }
        public DbSet<View.OperatorYearMoney> OperatorYearMoney { get; set; }
        public DbSet<View.GroupFiveDayAvg> GroupFiveDayAvg { get; set; }
        public DbSet<Data.Month.GroupMonthWinOrLoseTick> GroupMonthWinOrLoseTick { get; set; }
        public DbSet<Data.Year.GroupYearWinOrLoseTick> GroupYearWinOrLoseTick { get; set; }
        public DbSet<Data.Day.CompanyDayChange> CompanyDayChange { get; set; }
        public DbSet<Data.Month.CompanyMonthSum> CompanyMonthSum { get; set; }
        public DbSet<Data.Year.CompanyYearSum> CompanyYearSum { get; set; }
        public DbSet<Data.Day.CompanyFiveDayAvg> CompanyFiveDayAvg { get; set; }
        public DbSet<Sys.Company> Company { get; set; }
        public DbSet<Data.Week.CompanyWeekSum> CompanyWeekSum { get; set; }
        public DbSet<Data.Year.BrokerageYearTradeInfo> BrokerageYearTradeInfo { get; set; }
        #endregion



        public DBManager() : base(CONNECTION_STRING) { }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约      
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();//防止黑幕交易 要不然每次都要访问 EdmMetadata这个表                 
        }
    }
}